package com.junzhiit.nengji.cms.web.vo;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import com.bainaeco.framework.base.BaseObject;

public class MenuVO extends BaseObject{
	
	private static final long serialVersionUID = 1L;

	private String id;

	private String code;
	
	private String name;
	
	private String icon;
	
	private String url;
	
	private String parentId;
	
	private Integer level;
	
	private Integer childCount;

	private Integer sort;
	
	private String path;
	
	private String platform;
	
	private List<MenuVO> child  = new ArrayList<MenuVO>();
	
	public void addChild(MenuVO menu){
		child.add(menu);
	}
	
	public void sortChild(){
		if(child.size() != 0){
			Collections.sort(child, new SortComparator());
			for(int i = 0,size = child.size(); i < size; i++){
				child.get(i).sortChild();
			}
		}
	}
	
	public class SortComparator implements Comparator<MenuVO>{
		public int compare(MenuVO o1, MenuVO o2) {
			return o1.getSort() < o2.getSort()? -1 :(o1.getSort() == o2.getSort() ? 0 : 1);
		}
	}
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

	public Integer getChildCount() {
		return childCount;
	}

	public void setChildCount(Integer childCount) {
		this.childCount = childCount;
	}

	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}
	
	public String getPlatform() {
		return platform;
	}

	public void setPlatform(String platform) {
		this.platform = platform;
	}

	public List<MenuVO> getChild() {
		return child;
	}

	public void setChild(List<MenuVO> child) {
		this.child = child;
	}
}
